﻿@{
    ViewBag.Title = "基本配置";
}

@model Himall.Web.Models.SiteSettingModel


<div class="container">
    <ul class="nav nav-tabs-custom clearfix">
        <strong>公众号管理</strong>
        <li class="active"><a href="#">公众号设置</a></li>
    </ul>
    @using (Html.BeginForm("BasicSettings", "WeiXin", FormMethod.Post, new { @class = "form-horizontal form-pt0" }))
    {
        <h3 class="table-hd">自定义菜单权限配置<span class="help-default" style="margin-left:50px">提示：如需自定义微信菜单，需配置公众号AppId及AppSecret</span></h3>
        <div class="form-group">
            <label for="" class="col-sm-2 control-label">微信AppId</label>
            <div class="col-sm-4">
                @Html.EditorFor(item => item.WeixinAppId, new { htmlAttributes = new { @class = "form-control input-sm" } })
            </div>
        </div>
        <div class="form-group">
            <label for="" class="col-sm-2 control-label">微信AppSecret</label>
            <div class="col-sm-4">
                @Html.EditorFor(item => item.WeixinAppSecret, new { htmlAttributes = new { @class = "form-control input-sm" } })
            </div>

        </div>


        <h3 class="table-hd">自定义菜单权限配置<span class="help-default" style="margin-left:50px">提示：URL及Token需在微信公众号平台进行配置</span></h3>
        <div class="form-group">
            <label for="" class="col-sm-2 control-label">URL：</label>
            <div class="col-sm-4 form-control-static">
                @ViewBag.Url
            </div>
        </div>
        <div class="form-group">
            <label for="" class="col-sm-2 control-label">微信ToKen：</label>
            <div class="col-sm-4 form-control-static">
                @Model.WeixinToKen
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary">保存</button>
            </div>
        </div>
    }
</div>



<script>
$('button').click(function () {
    var loading = showLoading();
    var appId = $('input[name="WeixinAppId"]').val();
    var appSecret = $('input[name="WeixinAppSecret"]').val();
    $.post('./SaveWeiXinSettings', { weixinAppId: appId, WeixinAppSecret: appSecret }, function (result) {
        loading.close();
        if (result.success) {
            $.dialog.tips('保存成功');
            window.location.reload();
        }
        else
            $.dialog.alert('保存失败！' + result.msg);
    });
});
</script>
